living document:
https://docs.google.com/document/d/1omDa3lDHnNP23T0amVv_oeEuBL7Hl73e/edit#heading=h.gjdgxs
02/05/2022
living document:
https://docs.google.com/document/d/1omDa3lDHnNP23T0amVv_oeEuBL7Hl73e/edit#heading=h.gjdgxs
R online resourcesR for Data Science: https://r4ds.had.co.nz
R packagesReLTER, lterdatasampler, EML )
RStudio (https://www.rstudio.com/products/rstudio/download/)
New Project -> Version Control
Encourages collaboration “out of the box”. https://github.com/micha-silver/ReLTER_demo
Please execute the code before continue the presentation
# Install some standard spatial packages from CRAN
if (!require("sf", quietly = TRUE))
install.packages("sf")
if (!require("terra", quietly = TRUE))
install.packages("terra")
# package from Bioconductor
if (!require("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install()
BiocManager::install("EBImage")
## Warning: package(s) not installed when version(s) same as current; use `force = TRUE` to ## re-install: 'EBImage'
# remote
# Install development package from github
if (!require("remotes", quietly = TRUE))
install.packages("remotes")
ReLTER installation# Install the dev version of ReLTER for use new function
if (!require("ReLTER", quietly = TRUE))
remotes::install_github("ropensci/ReLTER", ref = 'dev__withImprovements')
## ReLTER is specially drafted for the LTER community.
##
## To contribute to the improvement of this package, join the group of
## developers (https://github.com/ropensci/ReLTER).
##
## If you use this package, please cite as:
##
## Alessandro Oggioni, Micha Silver, Luigi Ranghetti & Paolo Tagliolato.
## (2021) oggioniale/ReLTER: ReLTER v1.1.0 (1.1.0). Zenodo.
## https://doi.org/10.5281/zenodo.5576813
After installing, we need to load the packages into this R session.
# Convenient way to load list of packages
pkg_list <- c("sf", "terra", "ReLTER", "tmap")
lapply(pkg_list, require, character.only = TRUE)
## [[1]] ## [1] TRUE ## ## [[2]] ## [1] TRUE ## ## [[3]] ## [1] TRUE ## ## [[4]] ## [1] TRUE
R Spatialsf, terraterra, starstmap, leaflet, ggmap, (plot)ReLTER relies on the data entered into DEIMS-SDR. However sometimes there are:
Query for Site Manager
# Multiple sites in the KISKUN region of Hungary
kiskun <- ReLTER::get_ilter_generalinfo(country_name = "Hungary",
site_name = "KISKUN")
# How many sites?
print(paste("In Kiskun region: ", length(kiskun$title), "sites"))
## [1] "In Kiskun region: 8 sites"
(kiskun$title)
## [1] "Kiskun Forest Reserve Sites, KISKUN LTER - Hungary" ## [2] "VULCAN Kiskunsag, KISKUN LTER - Hungary" ## [3] "Kiskun Restoration Experiments, KISKUN LTER - Hungary" ## [4] "Kiskun Site Network (Jedlik), KISKUN LTER - Hungary" ## [5] "KISKUN LTER - Hungary" ## [6] "LTER Fulophaza Site, KISKUN LTER - Hungary" ## [7] "Bugac-Bocsa-Orgovany Site, KISKUN LTER - Hungary" ## [8] "Orgovany Site, KISKUN LTER - Hungary"
# Which site? Bugac-Bocsa bugac_id <- kiskun[7,]$uri bugac_details <- ReLTER::get_site_info(bugac_id,"Contacts") (bugac_details$generalInfo.siteManager[[1]]['name'])
## name ## 1 Gábor Ónodi
Now query for boundary
bugac_polygon <- ReLTER::get_site_info(bugac_id, "Boundaries")
## ## ---- ## This site does not have boundaries uploaded to DEIMS-SDR. ## Please verify in the site page: https://deims.org/609e5959-8cd8-44a0-ab42-eda521cd452a ## ----
str(bugac_polygon)
## tibble [1 × 9] (S3: tbl_df/tbl/data.frame) ## $ title : chr "Bugac-Bocsa-Orgovany Site, KISKUN LTER - Hungary" ## $ uri : chr "https://deims.org/609e5959-8cd8-44a0-ab42-eda521cd452a" ## $ boundaries : logi NA ## $ geoCoord : chr "POINT (19.5281 46.7183)" ## $ country :List of 1 ## ..$ : chr "Hungary" ## $ geoElev.avg : int 112 ## $ geoElev.min : int 105 ## $ geoElev.max : int 120 ## $ geoElev.unit: chr "msl"
# No geometry
paradiso <- ReLTER::get_ilter_generalinfo(country_name = "Italy",
site_name = "Gran Paradiso")
(paradiso$title)
## [1] "IT23 - Gran Paradiso National Park - Italy" ## [2] "Gran Paradiso National Park - Italy"
# Choose the second paradiso_id <- paradiso[2,]$uri paradiso_details <- ReLTER::get_site_info(paradiso_id, "Contacts") # Multiple names for metadata: paradiso_details$generalInfo.metadataProvider[[1]]['name']
## name ## 1 Alessandro Oggioni ## 2 Ramona Viterbi
# But what about funding agency paradiso_details$generalInfo.fundingAgency
## [1] NA
Functions within ReLTER help to acquire certain Earth Observation datasets.
The get_site_ODS() function offers to ReLTER users access to the OpenDataScience Europe (ODS) archive (https://maps.opendatascience.eu/) with landcover, NDVI, natura2000, Corine landcover, and OSM features, all at 30 meter pixel resolution. Cropping to site boundaries is done in the cloud, and due to the Cloud Optimized Geotiff (COG) format, downloads are quite small.
# Get DEIMS ID for Kis-Balaton site
kis_balaton <- ReLTER::get_ilter_generalinfo(country_name = "Hungary",
site_name = "Kis-Balaton")
kb_id = kis_balaton$uri
kb_polygon = ReLTER::get_site_info(kb_id, "Boundaries")
# Now acquire landcover and NDVI from ODS
kb_landcover = ReLTER::get_site_ODS(kb_id, dataset = "landcover")
kb_ndvi_summer = ReLTER::get_site_ODS(kb_id, "ndvi_summer")
# Plot maps
tm_basemap("OpenStreetMap.Mapnik") +
tm_shape(kb_polygon) +
tm_borders(col = "purple") +
tm_shape(kb_ndvi_summer) +
tm_raster(alpha=0.7, palette = "RdYlGn")
## Variable(s) "NA" contains positive and negative values, so midpoint is set to 0. Set midpoint = NA to show the full spectrum of the color palette.
tm_basemap("OpenStreetMap.Mapnik") +
tm_shape(kb_polygon) +
tm_borders(col = "purple") +
tm_shape(kb_landcover) +
tm_raster(alpha=0.7, palette = "Set1")
lezirias <- ReLTER::get_ilter_generalinfo(country_name = "Portugal",
site_name = "Companhia")
lezirias_id = lezirias$uri
lezirias_polygon = ReLTER::get_site_info(lezirias_id, "Boundaries")
# Now acquire spring NDVI from OSD
lezirias_ndvi_spring = ReLTER::get_site_ODS(lezirias_id, "ndvi_spring")
# Plot maps
tm_basemap("OpenStreetMap.Mapnik") +
tm_shape(lezirias_polygon) +
tm_borders(col = "purple") +
tm_shape(lezirias_ndvi_spring) +
tm_raster(alpha=0.7, palette = "RdYlGn")
## Variable(s) "NA" contains positive and negative values, so midpoint is set to 0. Set midpoint = NA to show the full spectrum of the color palette.
The function outputs a raster. We can save to Geotiff for use in other GIS
class(lezirias_ndvi_spring)
## [1] "SpatRaster" ## attr(,"package") ## [1] "terra"
writeRaster(x = lezirias_ndvi_spring,
filename = "lezirias_ndvi_spring.tif",
overwrite = TRUE)
Functions within ReLTER help to acquire certain third parties biodiversity datasets. The get_site_speciesOccurrences function1, offers to ReLTER users access to the occurrence records from GBIF (via rgbif R package), iNaturalist and OBIS carried out within the boundaries of the site.
Coauthor of these functions are Martina Zilioli and Paolo Tagliolato.
1 get_site_speciesOccurrences, map_occ_gbif2elter and save_occ_eLTER_reporting_Archive currently are delivered only with dev__withImprovements branch of ReLTER
DEIMS.iD of eLTER site Gulf Of Venice (GOV) GOVid <- "https://deims.org/758087d7-231f-4f07-bd7e-6922e0c283fd" resGOV <- ReLTER::get_site_speciesOccurrences( deimsid = GOVid, list_DS = "obis", show_map = TRUE, limit = 10)
# DEIMS.iD of eLTER the Saldur River Catchment site
saldur_id <- "https://deims.org/97ff6180-e5d1-45f2-a559-8a7872eb26b1"
occ_SRC <- ReLTER::get_site_speciesOccurrences(
deimsid = saldur_id, list_DS = c("gbif", "inat"), show_map = TRUE, limit = 100)
Fields mapping among the three data source schemas (i.e., GBIF, iNaturalist, OBIS) and the eLTER data-reporting template (Peterseil et al., 2021) was carried out so as to design ReLTER functions: map_occ_gbif2elter and save_occ_eLTER_reporting_Archive.
Below an example of iNaturalist export data, for the Saldur River Catchment site.
library(dplyr)
saldurid <- "https://deims.org/97ff6180-e5d1-45f2-a559-8a7872eb26b1"
resSaldur <- ReLTER::get_site_speciesOccurrences(
deimsid = saldurid, list_DS = c("gbif", "inat"), show_map = FALSE, limit = 20,
exclude_inat_from_gbif = TRUE)
# iNaturalist
tblSaldur_inat <- tibble::as_tibble(resSaldur$inat)
outInat <- tblSaldur_inat %>%
ReLTER::map_occ_inat2elter(deimsid = saldurid)
ReLTER::save_occ_eLTER_reporting_Archive(outInat)
The eLTER useful archive created is:
ReLTER has implemented some revealing visualizations of the various parameters collected at LTER sites. One visualization is the pie chart of environmental parameters.
In an example above the DEIMS ID of Kis Balaton (Kiskun LTER) was found. We’ll use that site to show a pie chart of environmental variables collected in that site.
ReLTER::produce_site_parameters_pie(kb_id)
## # A tibble: 8 × 4 ## parameterGroups n freq perc ## <chr> <int> <dbl> <chr> ## 1 agricultural parameters 1 0.0208 2% ## 2 atmospheric parameters 1 0.0208 2% ## 3 biological parameters 16 0.333 33% ## 4 chemical parameters 16 0.333 33% ## 5 ecosystem parameters 8 0.167 17% ## 6 physical parameters 1 0.0208 2% ## 7 soil parameters 1 0.0208 2% ## 8 water parameters 4 0.0833 8%
Similarly, a “waffle” chart can be produced.
ReLTER::produce_site_parameters_waffle(kb_id)
## # A tibble: 8 × 4 ## parameterGroups n freq label ## <chr> <int> <dbl> <chr> ## 1 agricultural parameters 1 0.0208 2% ## 2 atmospheric parameters 1 0.0208 2% ## 3 biological parameters 16 0.333 33% ## 4 chemical parameters 16 0.333 33% ## 5 ecosystem parameters 8 0.167 17% ## 6 physical parameters 1 0.0208 2% ## 7 soil parameters 1 0.0208 2% ## 8 water parameters 4 0.0833 8%
This example uses the LTER network in Greece. Call the produce_network_points_map() function (requires both DEIMS network ID and the three letter ISO code for the country to be mapped) to get all sites in a country.
lter_greece_id = "https://deims.org/networks/83453a6c-792d-4549-9dbb-c17ced2e0cc3"
lter_greece <- ReLTER::produce_network_points_map(lter_greece_id, "GRC")
grc <- readRDS("gadm36_GRC_0_sp.rds") # available from `produce_network_points_map()
grc
## class : SpatialPolygonsDataFrame ## features : 1 ## extent : 19.37236, 29.6457, 34.80069, 41.74801 (xmin, xmax, ymin, ymax) ## crs : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 ## variables : 2 ## names : GID_0, NAME_0 ## value : GRC, Greece